using System;
using System.Collections.Generic;
using System.Text;
using DTO;
using DAL;
using Utility;

namespace BUS
{
    public class DieuKienSuDung_BUS
    {
        public static void Insert(DieuKienSuDung_DTO dieuKienSuDung)
        {
            DieuKienSuDung_DAL dieuKienSuDungDAL = new DieuKienSuDung_DAL();
            dieuKienSuDungDAL.Insert(dieuKienSuDung);
        }
        public static void Update(DieuKienSuDung_DTO dieuKienSuDung)
        {
            DieuKienSuDung_DAL dieuKienSuDungDAL = new DieuKienSuDung_DAL();
            dieuKienSuDungDAL.Update(dieuKienSuDung);
        }
        public static void Delete(int iD)
        {
            DieuKienSuDung_DAL dieuKienSuDungDAL = new DieuKienSuDung_DAL();
            dieuKienSuDungDAL.Delete(iD);
        }
        public static tbDieuKienSuDungCollection Get(string where,
            int pageindex,
            int pagesize,
            string orderby,
            string orderdirection,
            out int total)
        {
            DieuKienSuDung_DAL dieuKienSuDungDAL = new DieuKienSuDung_DAL();
            return dieuKienSuDungDAL.Get(where, pageindex, pagesize, orderby, orderdirection, out total);
        }
        public static tbDieuKienSuDungCollection GetAll()
        {
            int total = 0;
            Criteria cri = new Criteria();
            DieuKienSuDung_DAL dieuKienSuDungDAL = new DieuKienSuDung_DAL();
            return dieuKienSuDungDAL.Get(cri.Criter, 0, 0, tbDieuKienSuDungColumns.ID.ToString(), OrderDirection.ASC.ToString(), out total);
        }
        public static DieuKienSuDung_DTO GetByID(int iD)
        {
            int total = 0;
            Criteria cri = new Criteria();
            cri.add(Condition.AND, tbDieuKienSuDungColumns.MaMH.ToString(), Condition.EQUAL, iD);
            DieuKienSuDung_DAL dieuKienSuDungDAL = new DieuKienSuDung_DAL();
            tbDieuKienSuDungCollection dieuKienSuDungCollection = dieuKienSuDungDAL.Get(cri.Criter,
                0, 0, tbDieuKienSuDungColumns.ID.ToString(), OrderDirection.ASC.ToString(), out total);
            if (dieuKienSuDungCollection.Count > 0)
                return dieuKienSuDungCollection[0];
            return null;
        }
        public static tbDieuKienSuDungCollection GetLimited(int number)
        {
            int total = 0;
            Criteria cri = new Criteria();
            DieuKienSuDung_DAL dieuKienSuDungDAL = new DieuKienSuDung_DAL();
            return dieuKienSuDungDAL.Get(cri.Criter, 1, number,
                tbDieuKienSuDungColumns.ID.ToString(), OrderDirection.DESC.ToString(), out total);
        }
        public static tbDieuKienSuDungCollection GetPromotion(int number)
        {
            int total = 0;
            Criteria cri = new Criteria();
            DieuKienSuDung_DAL dieuKienSuDungDAL = new DieuKienSuDung_DAL();
            return dieuKienSuDungDAL.Get(cri.Criter, 1, number,
                tbDieuKienSuDungColumns.ID.ToString(), OrderDirection.DESC.ToString(), out total);
        }
    }
}
